<template>
	<view class="app">
		<getheader :headertype="'detail'"></getheader>
		<proswiper :imglist="proInfo['imglist']"></proswiper>
		<view class="introduce column">
			<text class="title">{{ proInfo['name']}}</text>
			<view class="price-wrap row">
				<view class="mix-price-view">
					<text>￥</text>
					<text class="price">{{ proInfo['money'] }}</text>
					<text>.00</text>
				</view>
				<text class="m-price">￥{{ proInfo['price'] }}</text>
				<text class="tag">免邮费</text>
			</view>
			<view class="bot row">
				<text class="fill">销量: {{ proInfo['integral'] }}</text>
				<text class="fill">库存: 21</text>
				<text class="fill">浏览量: 245</text>
			</view>
		</view>

		<view class="share-wrap row">
			<view class="icon row">
				<text class="mix-icon icon-iconfontxingxing"></text>
				<text>分享</text>
			</view>
			<text class="tit">发给好友看看吧~</text>
			<text class="mix-icon icon-bangzhu1"></text>

			<!-- #ifdef MP-WEIXIN -->
			<button type="primary" open-type="share">
				<view class="btn">
					立即分享
					<text class="mix-icon icon-you"></text>
				</view>
			</button>
			<!-- #endif -->
			<!-- #ifndef MP-WEIXIN -->
			<view class="btn">
				立即分享
				<text class="mix-icon icon-you"></text>
			</view>
			<!-- #endif -->
		</view>

		<view class="c-list">
			<view class="row b-b">
				<text class="tit">购买类型</text>
				<view class="con">
					<text class="attr">规格：{{ proInfo['typename'] }}</text>
				</view>
				<text class="mix-icon icon-you"></text>
			</view>
			<view class="row b-b">
				<text class="tit">优惠券</text>
				<text class="con red">领取优惠券</text>
				<text class="mix-icon icon-you"></text>
			</view>
			<view class="row b-b">
				<text class="tit">促销活动</text>
				<view class="con-list fill column">
					<text>新人首单送20元无门槛代金券</text>
					<text>订单满50减10</text>
					<text>订单满100减30</text>
					<text>单笔购买满两件免邮费</text>
				</view>
			</view>
			<view class="row b-b">
				<text class="tit">服务</text>
				<view class="con">
					<text class="service">7天无理由退换货 ·</text>
					<text class="service">假一赔十 ·</text>
				</view>
			</view>
		</view>

		<view class="rating-wrap column">
			<view class="e-header">
				<text class="tit">商品评价</text>
				<text>(25)</text>
				<text class="tip">好评率 100%</text>
				<text class="mix-icon icon-you"></text>
			</view>
		</view>
		<view class="detail-desc">
			<view class="d-header center">
				<text>图文详情</text>
			</view>
			<img class="images" v-for="item in proInfo['content']" :src="item" mode="widthFix">
		</view>

		<view class="mix-botoom-operation row">
			<view class="nav-group row">
				<view class="nav column center" @click="gotoindex()">
					<text class="mix-icon icon-home"></text>
					<text class="tit">首页</text>
				</view>
				<view class="nav column center" @click="gotocart()">
					<text class="mix-icon icon-gouwuche"></text>
					<text class="tit">购物车</text>
					<view class="number center">
						<text>7</text>
					</view>
				</view>
				<view class="nav column center" @click="changeFav()">
					<text class="mix-icon icon-shoucang-1"></text>
					<text class="tit">收藏</text>
				</view>
			</view>
			<view class="btn-group row">
				<view class="btn center" @click="oprationClick('cart')">
					<text>加入购物车</text>
				</view>
				<view class="btn center" @click="oprationClick('buy')">
					<text>立即购买</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import proswiper from '@/pages/components/proswiper.vue';
	import getheader from '@/pages/components/getheader.vue';
	export default {
		components: {
			proswiper,
			getheader,
		},
		data() {
			return {
				id: '',
				proInfo: [],
			}
		},
		onLoad() {
			//	---- 这里获取id -----
			this.id = 2;
			this.startFnc();
			this.proInfo[1];
		},
		methods: {
			startFnc() {
				this.getProinfo();
			},
			// ----- 通过ID获取产品详情 -----
			getProinfo() {
				// ----- 这里是获取数据源部分 ----
				this.showLoading(1);
				this.proInfo = this.globals.proList[this.id];

				this.hideLoading(500);
			},
			// ----- 跳转首页 -----
			gotoindex() {
				let url = '/pages/index/index';
				this.tabTo(url);
			},
			// ----- 跳转购物车以及操作 -----
			gotocart() {
				let url = '/pages/cart/cart';
				this.tabTo(url);
			},
			// ----- 收藏以及操作 -----
			changeFav() {
				//let url = '/pages/cart/cart';
				//tabTo(url);
				//this.myclick();
				let title = '这里是对收藏操作，操作完成';
				this.showMsg(title);
			},
			// ----- 购物车与购买 -----
			oprationClick(type) {
				let title = '购物车已更新';
				this.showMsg(title);

				if (type == 'buy') {
					let url = '/pages/cart/cart';
					this.tabTo(url);
				}
			},
		}
	}
</script>

<style>
	page {
		background-color: #f5f5f5;
	}
</style>
<style scoped lang='scss'>
	.mix-price-view {
		color: $base-color;
	}

	.price {
		font-weight: 700;
		font-size: 4vw;
	}

	.app {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		&:after {
			content: '';
			display: block;
			width: 100%;
			height: 100rpx;
		}
	}

	/* 标题简介 */
	.introduce {
		background: #fff;
		padding: 1vw 2vw;

		.title {
			min-height: 5vw;
			font-size: 3.5vw;
			color: #333;
			line-height: 5vw;
			font-weight: 700;
		}

		.price-wrap {
			min-height: 5vw;
			margin-top: 2vw;
			font-size: 3vw;
		}

		.m-price {
			margin: 0 1vw 0 2%;
			color: #999;
			text-decoration: line-through;
		}

		.tag {
			transform: translateY(4rpx);
			padding: 0 1vw;
			margin-left: 1vw;
			background: $base-color;
			font-size: 2vw;
			color: #fff;
			line-height: 3vw;
			border-radius: 1rpx;
			position: relative;
			bottom: 0;
		}

		.bot {
			padding: 2vw 0 1vw 1vw;
			font-size: 2.5vw;
			color: #999;
		}
	}

	/* 分享 */
	.share-wrap {
		background: linear-gradient(to right, #fdf5f6, #fbebf6);
		height: 76rpx;
		padding: 0 30rpx;
		color: $base-color;

		.icon {
			width: 90rpx;
			height: 30rpx;
			border: 1px solid $base-color;
			border-radius: 4rpx;
			position: relative;
			overflow: hidden;
			font-size: 22rpx;

			&:after {
				position: absolute;
				left: -20rpx;
				top: -12rpx;
				content: '';
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				background-color: $base-color;
			}
		}

		.icon-iconfontxingxing {
			position: relative;
			z-index: 1;
			font-size: 24rpx;
			margin-left: 2rpx;
			margin-right: 10rpx;
			color: #fff;
		}

		.tit {
			flex: 1;
			font-size: 26rpx;
			color: #666;
			margin-left: 14rpx;
		}

		.icon-bangzhu1 {
			padding: 10rpx;
			font-size: 30rpx;
			display: none;
		}

		.btn {
			padding-left: 20rpx;
			font-size: 24rpx;
			color: $base-color;
		}

		.icon-you {
			font-size: 22rpx;
			margin-left: 4rpx;
			color: $base-color;
		}
	}

	.c-list {
		font-size: 26rpx;
		color: #888;
		background: #fff;

		.row {
			min-height: 82rpx;
			padding: 16rpx 30rpx;
			position: relative;

			&:after {
				border-color: #eaeaea;
			}

			&:last-child:after {
				border: 0;
			}
		}

		.tit {
			width: 140rpx;
		}

		.con {
			flex: 1;
			color: #333;

			.attr {
				margin-right: 10rpx;
			}

			.service {
				margin-right: 30rpx;

				&:last-child {
					margin: 0;
				}
			}
		}

		.con-list {
			color: #333;

			text {
				line-height: 40rpx;
			}
		}

		.red {
			color: $base-color;
		}

		.icon-you {
			font-size: 24rpx;
			color: #999;
		}
	}

	/* 评价 */
	.rating-wrap {
		padding: 20rpx 30rpx 0rpx;
		background: #fff;
		margin-top: 12rpx;

		&.no-data {
			padding: 10rpx 30rpx 10rpx;
		}

		.e-header {
			display: flex;
			align-items: center;
			height: 70rpx;
			font-size: 28rpx;
			color: #333;
		}

		.tit {
			font-size: 32rpx;
			color: #333;
			font-weight: 700;
			margin-right: 4rpx;
		}

		.tip {
			flex: 1;
			font-size: 26rpx;
			color: #999;
			text-align: right;
		}

		.icon-you {
			margin-left: 8rpx;
			font-size: 24rpx;
			color: #999;
		}

		.mix-rating-item::after {
			border: 0;
		}
	}

	/*  详情 */
	.detail-desc {
		margin-top: 12rpx;
		background: #fff;

		.d-header {
			height: 80rpx;
			font-size: 30rpx;
			color: #333;

			text {
				margin: 0 20rpx;
			}

			&:before,
			&:after {
				content: '';
				width: 60rpx;
				border-bottom: 1px solid #ccc;
			}
		}

		.images {
			width: 100%;
		}
	}

	/* ----- 底部按钮 ---- */

	.mix-botoom-operation {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 90;
		width: 100%;
		height: 13vw;
		background-color: #fff;
		box-shadow: 0 -2rpx 10rpx 0 rgba(0, 0, 0, .1);
		box-sizing: content-box;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	.nav-group {
		padding-left: 6rpx;

		.nav {
			width: 12vw;
			height: 11vw;
			color: $darkblack;
			position: relative;

			&.active {
				color: $base-color;
			}
		}

		.tit {
			font-size: 2vw;
		}

		.mix-icon {
			height: 6vw;
			line-height: 6vw;
			font-size: 5vw;
			margin-bottom: 0.5vw;
		}

		.number {
			position: absolute;
			right: 10%;
			top: 0.5vw;
			min-width: 10%;
			height: 3.5vw;
			padding: 0 10% 0 10%;
			font-size: 1vw;
			color: $white;
			background-color: $base-color;
			border-radius: 2vw;
		}
	}

	.btn-group {
		flex: 1;
		margin: 0 1% 0 1%;
		overflow: hidden;

		.btn {
			flex: 1;
			height: 8.5vw;
			font-size: 3.5vw;
			color: $white;
			background-color: orange;
			border-radius: 10vw 0 0 10vw;

			&:last-child {
				background-color: $base-color;
				border-radius: 0 10vw 10vw 0;
			}
		}
	}
</style>
